<template>
  <div>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="25%">
      <el-form ref="passwordForm" :model="form" label-width="70px" :rules="rules">
        <el-form-item label="旧密码" prop="oldPassword">
          <el-input size="small" type="password" v-model="form.oldPassword" placeholder="请输入旧密码"></el-input>
        </el-form-item>
        <el-form-item label="新密码" prop="newPassword">
          <el-input size="small" type="password" v-model="form.newPassword" placeholder="请输入新密码"></el-input>
        </el-form-item>
        <el-form-item label="新密码" prop="newPassword1">
          <el-input size="small" type="password" v-model="form.newPassword1" placeholder="请再次输入新密码"></el-input>
        </el-form-item>
        <!-- <el-form-item>
          <el-button type="text" size="small">取消</el-button>
          <el-button type="text" size="small"></el-button>
        </el-form-item> -->
      </el-form>
      <span>
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="addPassword()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'EditPassword',
  data () {
    return {
      title: '修改密码信息',
      dialogVisible: false,
      form: {
        oldPassword: '',
        newPassword: ''
      },
      rules: {
        newPassword: [
          { required: true, message: '请输入新密码', trigger: 'blur' },
          { min: 4, max: 8, message: '长度在 4 到 8 个字符', trigger: 'blur' }
        ],
        newPassword1: [
          { required: true, message: '两次新密码不一致', trigger: 'blur' },
          { min: 4, max: 8, message: '长度在 4 到 8 个字符', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 修改密码
    addPassword () {
      this.$refs.passwordForm.validate((valid) => {
        if (valid) {
          // const res = await EditPasswordAPI()
          // if (resizeBy.status === 200) {
          this.$message.success('修改成功')
          this.dialogVisible = false
          // } else {
          //   this.$message.error('修改失败')
          // }
        }
      })
    }
  }
}
</script>

<style lang="less" scoped></style>
